package snippets;

import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

import task.ConnectionDescription;

public class Snippet223ExpandBar {

	public static void main (String [] args) {
		Display display = new Display ();
		Shell shell = new Shell (display);
		shell.setLayout(new FillLayout());
		shell.setText("ExpandBar Example");
//		Image image = display.getSystemImage(SWT.ICON_QUESTION);

		ExpandBar bar = createExpandBar(shell, display, null);
		
		shell.setSize(400, 350);
		shell.open();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) {
				display.sleep ();
			}
		}
//		image.dispose();
		display.dispose();
	}
	public static ExpandBar createExpandBar(Composite parent, Display display, ConnectionDescription[] conns)
	{
		ExpandBar bar = new ExpandBar (parent, SWT.V_SCROLL);
		
		// First item
//		Composite composite = new Composite (bar, SWT.NONE);
//		GridLayout layout = new GridLayout ();
//		layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
//		layout.verticalSpacing = 10;
//		composite.setLayout(layout);
//		Button button = new Button (composite, SWT.PUSH);
//		button.setText("SWT.PUSH");
//		button = new Button (composite, SWT.RADIO);
//		button.setText("SWT.RADIO");
//		button = new Button (composite, SWT.CHECK);
//		button.setText("SWT.CHECK");
//		button = new Button (composite, SWT.TOGGLE);
//		button.setText("SWT.TOGGLE");
//		ExpandItem item0 = new ExpandItem (bar, SWT.NONE, 0);
//		item0.setText("Tasks");
//		item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
//		item0.setControl(composite);
//		item0.setImage(image);
		
		// Second item
		
		 
		Composite composite = new Composite (bar, SWT.NONE);
		GridLayout layout = new GridLayout (2, false);
		layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
		layout.verticalSpacing = 10;
		composite.setLayout(layout);	
		Label label = new Label (composite, SWT.NONE);
		label.setImage(display.getSystemImage(SWT.ICON_ERROR));
		label = new Label (composite, SWT.NONE);
		label.setText("SWT.ICON_ERROR");
		label = new Label (composite, SWT.NONE);
		label.setImage(display.getSystemImage(SWT.ICON_INFORMATION));
		label = new Label (composite, SWT.NONE);
		label.setText("SWT.ICON_INFORMATION");
		label = new Label (composite, SWT.NONE);
		label.setImage(display.getSystemImage(SWT.ICON_WARNING));
		label = new Label (composite, SWT.NONE);
		label.setText("SWT.ICON_WARNING");
		label = new Label (composite, SWT.NONE);
		label.setImage(display.getSystemImage(SWT.ICON_QUESTION));
		label = new Label (composite, SWT.NONE);
		label.setText("SWT.ICON_QUESTION");
		ExpandItem item1 = new ExpandItem (bar, SWT.NONE, 0);
		item1.setText("Tasks");
		item1.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
		item1.setControl(composite);
//		item1.setImage(image);
		
		// Third item
//		composite = new Composite (bar, SWT.NONE);
		composite = Snippet297Table.createTable(bar, display, conns);
//		layout = new GridLayout (2, true);
		layout = new GridLayout ();
		layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
		layout.verticalSpacing = 10;
		composite.setLayout(layout);
//		label = new Label (composite, SWT.NONE);
//		label.setText("Scale");	
//		new Scale (composite, SWT.NONE);
//		label = new Label (composite, SWT.NONE);
//		label.setText("Spinner");	
//		new Spinner (composite, SWT.BORDER);
//		label = new Label (composite, SWT.NONE);
//		label.setText("Slider");	
//		new Slider (composite, SWT.NONE);
		ExpandItem item2 = new ExpandItem (bar, SWT.NONE, 1);
		item2.setText("Database Connections");
		item2.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
		item2.setControl(composite);
//		item2.setImage(image);
		
		item1.setExpanded(true);
		bar.setSpacing(8);
		return bar;
	}
}
